<template>
  <div>
    <el-form v-if="pdata.type === 'freeze_fund'" ref="form" :model="form" label-width="150px">
      <el-form-item label="冻结款项的用户">
        <el-input class="w500" :value="form.user_info.nickname"></el-input>
      </el-form-item>
      <el-form-item label="冻结操作用户">
        <el-input class="w500" :value="form.opposite_info.nickname"></el-input>
      </el-form-item>
      <el-form-item label="本次冻结金额(元)">
        <el-input class="w500" :value="form.money | formatPrice"></el-input>
      </el-form-item>
      <el-form-item label="已解冻金额(元)">
        <el-input class="w500" :value="form.unfreeze_money | formatPrice"></el-input>
      </el-form-item>
      <el-form-item label="资金日志ID">
        <el-input class="w500" :value="form.fund_log_id"></el-input>
      </el-form-item>
      <el-form-item label="解冻原因">
        <el-input class="w500" type="textarea" :value="form.unfreeze_reason" autosize></el-input>
      </el-form-item>
      <el-form-item label="解冻状态">
        <el-radio-group :value="form.freeze_status">
          <el-radio :label="0">未全部解冻</el-radio>
          <el-radio :label="1">已全部解冻</el-radio>
        </el-radio-group>
      </el-form-item>
      <el-form-item>
        <el-button @click="goBack">返回</el-button>
      </el-form-item>
    </el-form>
    <el-form v-else-if="pdata.type === 'freeze_integral'" ref="form" :model="form" label-width="150px">
      <el-form-item label="冻结用户">
        <el-input class="w500" v-model="form.user_info.nickname"></el-input>
      </el-form-item>
      <el-form-item label="冻结操作的用户">
        <el-input class="w500" v-model="form.opposite_info.nickname"></el-input>
      </el-form-item>
      <el-form-item label="本次冻结积分">
        <el-input class="w500" v-model="form.integral"></el-input>
      </el-form-item>
      <el-form-item label="已解冻积分">
        <el-input class="w500" v-model="form.unfreeze_integral"></el-input>
      </el-form-item>
      <el-form-item label="积分日志ID">
        <el-input class="w500" v-model="form.integral_log_id"></el-input>
      </el-form-item>
      <el-form-item label="解冻原因">
        <el-input class="w500" type="textarea" :value="form.unfreeze_reason" autosize></el-input>
      </el-form-item>
      <el-form-item label="解冻状态">
        <el-radio-group v-model="form.freeze_status">
          <el-radio :label="0">未全部解冻</el-radio>
          <el-radio :label="1">已全部解冻</el-radio>
        </el-radio-group>
      </el-form-item>
      <el-form-item>
        <el-button @click="goBack">返回</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
  import { mapState } from 'vuex'

  export default {
    data: function () {
      return {
        action: ''
      }
    },
    filters: {
      formatPrice: function (value) {
        return Number(value / 100)
      }
    },
    components: {
    },
    computed: {
      ...mapState({
        pdata: state => state.cause.saveData,
        form: state => state.cause.info
      })
    },
    created () {
      if (this.pdata.type === 'freeze_fund') {
        this.action = 'fund'
      } else {
        this.action = 'integral'
      }
      this.getInfo()
      this.form.freeze_status = String(this.form.freeze_status)
    },
    methods: {
      async getInfo () {
        let payload = {
          obj_id: this.pdata.id,
          user_id: this.pdata.user_id,
          app_id: this.pdata.app_id,
          action: this.action
        }
        await this.$store.dispatch('cause/getInfo', payload)
      },
      goBack () {
        this.$router.go(-1)
      }
    }
  }
</script>
